package ru.cod.rs.managers;

import android.content.Context;

/**
 * Abstract Cyclic Manager
 * 
 * @author Suslov Vadim
 * 
 */
public abstract class AbstractManager extends Thread {

	protected Context context;
	private boolean ready;

	public AbstractManager() {

	}

	public AbstractManager(Context c) {
		context = c;
		ready = false;
	}

	/**
	 * main cycle
	 */
	@Override
	public void run() {
		while (ready) {
			execute();
		}
	}

	// /////////////////////////////////////////////

	protected abstract void execute();

	// /////////////////////////////////////////////
	/**
	 * @return the ready
	 */
	public boolean isReady() {
		return ready;
	}

	/**
	 * @param ready
	 *            the ready to set
	 */
	public void setReady(boolean ready) {
		this.ready = ready;
	}

	/**
	 * @return context
	 */
	public Context getContext() {
		return context;
	}
}
